#!/usr/bin/env python
# -*- coding: utf-8 -*-
#创建SocketServerTCP服务器：
import secrets
import binascii

def hexStrToBytes(hex_str):
    # hex_string = 'ffffffffffff'
    print(hex_str)
    byte_string = binascii.unhexlify(hex_str)
    return byte_string

def bytesToHexStr(bs):
    hex_str = binascii.hexlify(bs)
    return hex_str

#生成16位token
def getToken(n = 16):
    tokenbytes = secrets.token_bytes(16)
    tokenhex = bytesToHexStr(tokenbytes)
    return tokenhex